# -*- coding:utf-8 -*-
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer

from Apps.User.models import User


class UserSer(ModelSerializer):
    """
    用户序列化到列表时，使用
    """
    gender_display = serializers.CharField(source='get_gender_display', read_only=True)

    class Meta:
        model = User
        # fields = '__all__'
        exclude = ["password"]


class PostUserSer(ModelSerializer):
    "新增用户时  使用"

    def validate(self, attrs):
        return attrs

    class Meta:
        model = User
        fields = '__all__'
        # exclude = ["password"]


class UserSerializer(ModelSerializer):
    """
    创建人，修改人，通用序列化
    用于其他表中，创建人，修改人的显示
    """
    class Meta:
        model = User
        fields = ["avatar", "nickname"]
        # fields = "__all__"


class SelectUserSerializer(ModelSerializer):
    """
    下拉选择用户时使用
    """
    class Meta:
        model = User
        fields = ["id", "nickname"]
